<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
	<title>组件基础-监听子组件事件</title>
</head>
<body>


<div id="app">

  <custom-input
    v-bind:value="searchText"
    v-on:input="searchText = $event"
  >
  </custom-input>


  <custom-input v-model="searchText"></custom-input>
</div>



<script type="text/javascript">

Vue.component('custom-input', {
  props: ['value'],
  template: `
    <input
      v-bind:value="value"
      v-on:input="$emit('input', $event.target.value)"
    >
  `
})


var app=new Vue({
  el: '#app',
  data: {
    searchText:'test'
  },

})

</script>

</body>
</html>